// 构建树形结构函数
export function buildTree(data: any[], parentId = "0") {
  const tree = [];

  for (const item of data) {
    if (item.parentId === parentId) {
      const children = buildTree(data, item.id);
      if (children.length > 0) {
        // 加上父级前缀
        // children.forEach((child) => {
        //   child.path = `${item.path}/${child.path}`;
        // });
        item.children = children;
      }
      tree.push(item);
    }
  }

  // 按sort排序
  return tree.sort((a, b) => a.sort - b.sort);
}

export function numToString(data: any, list: string[]) {
  const copyData = unref(data);

  list.forEach((key) => {
    if (copyData[key] || copyData[key] === 0) {
      copyData[key] = copyData[key] + "";
    }
  });
  console.log(copyData, "copyData");
}
